package com.luochen.cdpt.repository;

import com.luochen.cdpt.eneity.EmpInfo;
import com.luochen.cdpt.eneity.QEmpInfo;
import com.querydsl.core.types.dsl.StringPath;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer;
import org.springframework.data.querydsl.binding.QuerydslBindings;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

@RepositoryRestResource(path = "/emp")
public interface IEmpInfoRepository extends PagingAndSortingRepository<EmpInfo,Long>,
        QuerydslPredicateExecutor<EmpInfo>, JpaSpecificationExecutor<EmpInfo>, QuerydslBinderCustomizer<QEmpInfo> {

    default void customize(QuerydslBindings bindings, QEmpInfo qEmpInfo) {
        bindings.bind(qEmpInfo.empname,qEmpInfo.empcde).first(
                (StringPath path, String value) -> path.contains(value));
    }
}
